package coml.allen.api.qos;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;

/**
 * @author sesshomaru
 * @date 2020/11/14 16:23
 */
public class Producer {

    public static void main(String[] args) throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();

        connectionFactory.setHost("192.168.1.102");
        connectionFactory.setPort(5672);
        connectionFactory.setVirtualHost("/");

        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();


        String exchange = "test_qos_ex";
        String routingKey = "confirm.save";

        String msg = "this is producer test confirm msg";
        for (int i = 5; i > 0; i--) {
            channel.basicPublish(exchange, routingKey, null, msg.getBytes());
        }
    }
}
